package com.kanche.bigbaby.collection.domain;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

//import com.kkche.bss.data.BBSDBHelper;
//import com.kkche.bss.utils.StringUtils;

/**
 * Created by zhangsl on 15/3/3.
 */
public class User implements Serializable {
    private String id;
    private String mobile;
    private String name;
    private String avatar;
    private String gender;
    private String publicPhone;
    private String companyName;
    private String companyAddress;
    private Address address;
    private String userType;
    private UserGroup userGroup;
    private SubstituteUser substituteUser;
    private String createAt;
    private boolean substituted;
    private boolean enabled;
    private VehicleStatistics vehicleStatistics;
    private Department department;
    private UserRole userRole;
    private String token;
    private String updateAt;

    //new
//
//    protected SubstituteInfo substituteUserInfo;
//
//    public SubstituteInfo getSubstituteUserInfo() {
//        return substituteUserInfo;
//    }
//
//    public void setSubstituteUserInfo(SubstituteInfo substituteUserInfo) {
//        this.substituteUserInfo = substituteUserInfo;
//    }

    public static class SubstituteServiceDate implements Serializable {
        private String begin;
        private String end;

        public String getBegin() {
            return begin;
        }

        public void setBegin(String begin) {
            this.begin = begin;
        }

        public String getEnd() {
            return end;
        }

        public void setEnd(String end) {
            this.end = end;
        }
    }
    public static class SubstituteInfo implements Serializable {
        private String id;
        private String level;
        private SubstituteServiceDate serviceDate;
        private int leftDays;
        private String status;  //"valid" -> "服务中", "expired" -> "已暂停", "invalid" -> "未开通"

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }


        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getLevel() {
            return level;
        }

        public void setLevel(String level) {
            this.level = level;
        }

        public SubstituteServiceDate getServiceDate() {
            return serviceDate;
        }

        public void setServiceDate(SubstituteServiceDate serviceDate) {
            this.serviceDate = serviceDate;
        }

        public int getLeftDays() {
            return leftDays;
        }

        public void setLeftDays(int leftDays) {
            this.leftDays = leftDays;
        }
    }



    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public UserRole getUserRole() {
        return userRole;
    }

    public void setUserRole(UserRole userRole) {
        this.userRole = userRole;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getPublicPhone() {
        return publicPhone;
    }

    public void setPublicPhone(String publicPhone) {
        this.publicPhone = publicPhone;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getCompanyAddress() {
        return companyAddress;
    }

    public void setCompanyAddress(String companyAddress) {
        this.companyAddress = companyAddress;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public UserGroup getUserGroup() {
        return userGroup;
    }

    public void setUserGroup(UserGroup userGroup) {
        this.userGroup = userGroup;
    }

    public SubstituteUser getSubstituteUser() {
        return substituteUser;
    }

    public void setSubstituteUser(SubstituteUser substituteUser) {
        this.substituteUser = substituteUser;
    }

    public String getCreateAt() {
        return createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public boolean isSubstituted() {
        return substituted;
    }

    public void setSubstituted(boolean substituted) {
        this.substituted = substituted;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public VehicleStatistics getVehicleStatistics() {
        return vehicleStatistics;
    }

    public void setVehicleStatistics(VehicleStatistics vehicleStatistics) {
        this.vehicleStatistics = vehicleStatistics;
    }

    private class VehicleStatistics implements Serializable {
        private int online;
        private int offline;
        private int sold;
        private int substitutePosition;
        private int occupiedPosition;
        private int substituteOffline;

        public int getOnline() {
            return online;
        }

        public void setOnline(int online) {
            this.online = online;
        }

        public int getOffline() {
            return offline;
        }

        public void setOffline(int offline) {
            this.offline = offline;
        }

        public int getSold() {
            return sold;
        }

        public void setSold(int sold) {
            this.sold = sold;
        }

        public int getSubstitutePosition() {
            return substitutePosition;
        }

        public void setSubstitutePosition(int substitutePosition) {
            this.substitutePosition = substitutePosition;
        }

        public int getOccupiedPosition() {
            return occupiedPosition;
        }

        public void setOccupiedPosition(int occupiedPosition) {
            this.occupiedPosition = occupiedPosition;
        }

        public int getSubstituteOffline() {
            return substituteOffline;
        }

        public void setSubstituteOffline(int substituteOffline) {
            this.substituteOffline = substituteOffline;
        }
    }

    public class Department implements Serializable {
        private String id;
        private String departmentType;
        private String name;
        private String comment;
        private String createAt;
        private String updateAt;
        private Address address;
        private List<String> privileges = new ArrayList<>();

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getDepartmentType() {
            return departmentType;
        }

        public void setDepartmentType(String departmentType) {
            this.departmentType = departmentType;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        public String getCreateAt() {
            return createAt;
        }

        public void setCreateAt(String createAt) {
            this.createAt = createAt;
        }

        public String getUpdateAt() {
            return updateAt;
        }

        public void setUpdateAt(String updateAt) {
            this.updateAt = updateAt;
        }

        public Address getAddress() {
            return address;
        }

        public void setAddress(Address address) {
            this.address = address;
        }

        public List<String> getPrivileges() {
            return privileges;
        }

        public void setPrivileges(List<String> privileges) {
            this.privileges = privileges;
        }
    }

    public class UserRole implements Serializable {
        private String id;
        private String label;
        private String name;
        private String userType;
        private String username;
        private List<String> privileges = new ArrayList<>();

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getUserType() {
            return userType;
        }

        public void setUserType(String userType) {
            this.userType = userType;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public List<String> getPrivileges() {
            return privileges;
        }

        public void setPrivileges(List<String> privileges) {
            this.privileges = privileges;
        }
    }

    public static Address addressFromJson(String json) {
        Gson gson = new Gson();
        Address address = gson.fromJson(json, new TypeToken<Address>() {
        }.getType());
        return address;
    }

    public static Department departmentFromJson(String json) {
        Gson gson = new Gson();
        Department department = gson.fromJson(json, new TypeToken<Department>() {
        }.getType());
        return department;
    }

    public static UserRole userRoleFromJson(String json) {
        Gson gson = new Gson();
        UserRole userRole = gson.fromJson(json, new TypeToken<UserRole>() {
        }.getType());
        return userRole;
    }

    public static UserGroup userGroupFromJson(String json) {
        Gson gson = new Gson();
        UserGroup userGroup = gson.fromJson(json, UserGroup.class);
        return userGroup;
    }


//    public ContentValues toContentValues() {
//        ContentValues values = new ContentValues();
//        Gson gson = new Gson();
//        values.put(BBSDBHelper.UserColumns.userid, id);
//        values.put(BBSDBHelper.UserColumns.mobile, mobile);
//        values.put(BBSDBHelper.UserColumns.name, name);
//        values.put(BBSDBHelper.UserColumns.avatar, avatar);
//        values.put(BBSDBHelper.UserColumns.gender, gender);
//        values.put(BBSDBHelper.UserColumns.token, token);
//        values.put(BBSDBHelper.UserColumns.publicPhone, publicPhone);
//        values.put(BBSDBHelper.UserColumns.companyName, companyName);
//        values.put(BBSDBHelper.UserColumns.companyAddress, companyAddress);
//        values.put(BBSDBHelper.UserColumns.address, gson.toJson(address));
//        values.put(BBSDBHelper.UserColumns.userType, userType);
//        values.put(BBSDBHelper.UserColumns.createAt, createAt);
//        values.put(BBSDBHelper.UserColumns.enabled, StringUtils.boolToInt(enabled));
//        values.put(BBSDBHelper.UserColumns.department, gson.toJson(department));
//        values.put(BBSDBHelper.UserColumns.userRole, gson.toJson(userRole));
//        values.put(BBSDBHelper.UserColumns.userGroup, gson.toJson(userGroup));
//        return values;
//    }

}